package com.briup.ch13;

import java.lang.reflect.Method;
import java.util.ArrayList;

/**
 * @Author briup-adam
 * @Date 2023/10/31 上午8:23
 * @Description
 **/

public class Question {
    public static void main(String[] args) {
        ArrayList<Integer> list = new ArrayList<>();
//        list.add("hello");
        Class<? extends ArrayList> aClass = list.getClass();
        try {
            Method add = aClass.getDeclaredMethod("add", Object.class);
            add.invoke(list,"Hello");
            add.invoke(list,123);
            add.invoke(list,3.14);
            System.out.println(list);
        } catch (Exception e) {
            e.printStackTrace();
        }

    }
}
